home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7364 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  54 lines

  1. Newsgroups: comp.lang.c++
  2. Path: in1.uu.net!pilchuck!news
  3. From: Meiyu Lin <linm@data-io.com>
  4. Subject: Re: Problem with Linked Lists
  5. X-Nntp-Posting-Host: inet-gw
  6. Content-Type: text/plain; charset=us-ascii
  7. Message-ID: <312CDFF3.7F4D@data-io.com>
  8. Sender: news@data-io.com (Usenet news)
  9. Content-Transfer-Encoding: 7bit
  10. Organization: Data I/O Corp.
  11. References: <312A46D7.608A@exis.net>
  12. Mime-Version: 1.0
  13. Date: Thu, 22 Feb 1996 21:28:19 GMT
  14. X-Mailer: Mozilla 2.0 (Win95; I)
  15.  
  16. Chandler Pitcher wrote:
  17. > Help!! I'm trying to create a "circular" list that wraps around again from end to
  18. > beginning, but I am having no luck at setting up a head pointer. The function simply reads names
  19. > from a file and puts them in the list, I am using the word "Stop" as a sentinel. Once the
  20. > function is finished, I try to assign the link to the head, but head is following along with
  21. > the current pointer. How do I keep head and current pointing to the same thing in the
  22. > beginning, but then separate thru the rest of the function. struct node*, and node* head are
  23. > assigned in the main.
  24. > void read_list(node*& head)
  25. > {
  26. >         head = new node;
  27. >         node *current = head;
  28. >         current = head;
  29. >         stringtype temp;
  30. >         infile>>temp;
  31. >         while (strcmp("Stop", temp))
  32. >         {
  33. >                 strcpy(current->name, temp);
  34. >                 outfile<<current->name<<" is added to the list."<<endl;
  35. >                 infile>>temp;
  36. >                 if (!strcmp("Stop", temp))
  37. >                         current->link = new node;
  38. >         };
  39. >         current->link = head;
  40. >         return;
  41. > };
  42. >         Thanks for any help!! I'm really lost at this point!!!
  43. > Chandler Pitcher          |
  44. > Virginia Beach, Virginia  |   O A K L A N D   R A I D E R S
  45. >     <pitch@exis.net>      |Seems you are very lost, why don't you try a book:
  46. C++ Inside & out by Bruce Eckel, McGrowHill this is a good CPP beginner 
  47. book, and is pretty easy to understand.
  48.  
  49. Meiyu
  50.